package stringStudy;

public class ReverseSentence {

    /**
     * JZ44 翻转单词序列
     * @param args
     */
    public static void main(String[] args) {

    }

    public String ReverseSentence(String str) {
        if ("".equals(str)){
            return "";
        }
        String[] ss = str.split(" ");
        StringBuilder sb = new StringBuilder();
        for (int i = ss.length - 1; i >= 0; i--){
            sb.append(ss[i]).append(" ");
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }
}
